package com.xt.purchasingsystem.controller.productionManagement;

import com.xt.purchasingsystem.dto.DFileDto;
import com.xt.purchasingsystem.dto.MApplyDto;
import com.xt.purchasingsystem.dto.ProductionOrderDto;
import com.xt.purchasingsystem.model.MApply;
import com.xt.purchasingsystem.service.productionManagementService.ProductPlanManagementService;
import com.xt.purchasingsystem.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import java.util.List;

/**
 * 生产管理--生产计划管理接口
 *
 * @author: 老姚
 * Date:  2020/4/19 11:04
 */
@RestController
@RequestMapping(value = "/productPlan")
public class ProductPlanManagementController {
    @Autowired
    private ProductPlanManagementService productPlanManagementService;

    //多条件分页获取可以生产计划登记的产品档案
    @PostMapping("/getAllPlanRegisterByPage")
    public Result getAllPlanRegisterByPage(@RequestBody DFileDto dFileDto) {
        return productPlanManagementService.getAllPlanRegisterByPage(dFileDto);
    }

    //提交生产计划的接口
    @PostMapping("/submitProductPlans")
    public Result submitProductPlans(@RequestBody List<MApply> mApplys) {
        return productPlanManagementService.submitProductPlans(mApplys);
    }

    // 分页查询所有未审核的生产计划的接口
    @GetMapping("/getAllMApplyByUnreviewed/{currNo}/{pageSize}")
    public Result getAllMApplyByUnreviewed(@PathVariable Integer currNo, @PathVariable Integer pageSize) {
        return productPlanManagementService.queryAllMApplyByUnreviewed(currNo, pageSize);
    }

    //审核生产计划的接口
    @PutMapping("/auditMApply")
    public Result auditMApply(@RequestBody MApply mApply) {
        return productPlanManagementService.auditMApply(mApply);
    }

    //多条件分页查询所有未派工的生产计划的接口
    @PostMapping("/getAllMApplyByNotWork")
    public Result getAllMApplyByNotWork(@RequestBody MApplyDto mApplyDto) {
        return productPlanManagementService.getAllMApplyByNotWork(mApplyDto);
    }

    //根据产品编号和生产数量查询此产品的工序及工序物料
    @GetMapping("/getMDesignProcedureDetailsVos/{productId}/{amount}")
    public Result getMDesignProcedureDetailsVos(@PathVariable String productId, @PathVariable Double amount) {
        return productPlanManagementService.getMDesignProcedureDetailsVos(productId, amount);
    }

    //提交生产派工单的接口
    @PostMapping("/submitProductionOrder")
    public Result submitProductionOrder(@RequestBody ProductionOrderDto productionOrderDto) {
        return productPlanManagementService.submitProductionOrder(productionOrderDto);
    }

    //分页查询所有未审核的生产总表的接口
    @GetMapping("/getAllUnreviewedByPage/{currNo}/{pageSize}")
    public Result getAllUnreviewedByPage(@PathVariable Integer currNo, @PathVariable Integer pageSize) {
        return productPlanManagementService.getAllUnreviewedByPage(currNo, pageSize);
    }

    //根据生产总表编号获取此生产的所有生产工序及工序物料
    @GetMapping("/getAllMProcedureAndModulesById/{id}")
    public Result getAllMProcedureAndModulesById(@PathVariable Integer id) {
        return productPlanManagementService.getAllMProcedureAndModulesById(id);
    }

    //审核生产派工单的接口
    @PostMapping("/reviewProductionDispatchOrder")
    public Result reviewProductionDispatchOrder(@RequestBody ProductionOrderDto productionOrderDto) {
      return   productPlanManagementService.reviewProductionDispatchOrder(productionOrderDto);
    }


}
